package com.feiyun.util;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import com.feiyun.model.dto.ResultVO;

/**
 * Function Desc:
 *
 * @author yan
 * @since 2023/3/20 22:28
 */
public class ResponseUtil {
    public static ResponseEntity<ResultVO<Void>> success() {
        return new ResponseEntity<>(new ResultVO<>(HttpStatus.OK.value(), null, null), HttpStatus.OK);
    }

    public static <T> ResponseEntity<ResultVO<T>> success(T data) {
        return new ResponseEntity<>(new ResultVO<>(HttpStatus.OK.value(), null, data), HttpStatus.OK);
    }

    public static <T> ResponseEntity<ResultVO<T>> success(String msg, T data) {
        return new ResponseEntity<>(new ResultVO<>(HttpStatus.OK.value(), msg, data), HttpStatus.OK);
    }

    public static <T> ResponseEntity<ResultVO<T>> exception(String msg, T data) {
        return new ResponseEntity<>(new ResultVO<>(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg, data), HttpStatus.OK);
    }

    public static <T> ResponseEntity<ResultVO<T>> exception(int code, String msg, T data) {
        return new ResponseEntity<>(new ResultVO<>(code, msg, data), HttpStatus.OK);
    }


}
